<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:67:"D:\phpStudy\WWW\oa\public/../application/admin\view\role\admin.html";i:1514512605;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>网站信息</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 角色列表</strong>&emsp;<a
            style="color: #3a4bfb;font-weight: bold " href="javascript:history.go(-1)">返回上一步</a></div>
    <div class="padding border-bottom">
        <!--<a class="button border-yellow" href=""><span class="icon-plus-square-o"></span> 添加内容</a>-->
    </div>
    <div id="div">
        <!--<table class="table table-hover text-center">
            <tr>
                <th width="5%">角色名</th>
                <th>角色描述</th>
                <th width="250">操作</th>
            </tr>
            <?php if(is_array($role) || $role instanceof \think\Collection || $role instanceof \think\Paginator): $i = 0; $__LIST__ = $role;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
            <tr>
                <td><?php echo $vo['role']; ?></td>
                <td><?php echo $vo['descript']; ?></td>
                <td>
                    <div class="button-group">
                        <a type="button" class="button border-main" href="<?php echo url('Role/rolesave'); ?>?id=<?php echo $vo['id']; ?>"><span
                                class="icon-edit"></span>修改</a>
                        <a class="button border-red" onclick="return del('<?php echo $vo['id']; ?>')"><span class="icon-trash-o"></span>
                            删除</a>
                    </div>
                </td>
            </tr>
            <?php endforeach; endif; else: echo "" ;endif; ?>
        </table>-->
        <!--自动渲染-->
        <!--<table class="layui-table" lay-data="{width: 892, height:332, url:'<?php echo url('Role/index_x'); ?>', page:true, id:'demo'}"
               lay-filter="demo">
            <thead>
            <tr>
                <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                <th lay-data="{field:'id', fixed: 'true',sort: true,}">ID</th>
                <th lay-data="{field:'role',fixed: 'true'}">角色</th>
                <th lay-data="{field:'descript',fixed: 'true'}">描述</th>
                <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo',fixed: 'true'}">操作</th>
            </tr>
            </thead>
        </table>
-->

        <!--转成静态表格-->
        <table lay-filter="demo">
            <thead>
            <tr>
                <th lay-data="{field:'id', sort:'true',align:'center'}">ID</th>
                <th lay-data="{field:'role', align:'center',edit: 'text', sort: true}">角色</th>
                <th lay-data="{field:'descript',edit: 'text', align:'center'}">描述</th>
                <th lay-data="{fixed: 'right', align:'center', toolbar: '#barDemo'}">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php if(is_array($role) || $role instanceof \think\Collection || $role instanceof \think\Paginator): $i = 0; $__LIST__ = $role;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$io): $mod = ($i % 2 );++$i;?>
            <tr>
                <td><?php echo $io['id']; ?></td>
                <td><?php echo $io['role']; ?></td>
                <td><?php echo $io['descript']; ?></td>
                <td lay-data="{fixed: 'right', align:'center', toolbar: '#barDemo'}">操作</td>
            </tr>
            <?php endforeach; endif; else: echo "" ;endif; ?>
            </tbody>
        </table>
        <!--方法渲染-->
        <!--<table class="layui-hide" id="test"></table>-->
    </div>

</div>
<div>
</div>

</body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<!--转化静态表格-->
<script>
    layui.use('table', function () {
        var table = layui.table;
//转换静态表格
        var index = layer.load(1);
        //关闭
        layer.close(index);
        //监听工具条
        //监听单元格编辑
        table.on('edit(demo)', function (obj) {
            //console.log(obj);
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field //得到字段
                , id = data.id
                ,submit='submit';
            $.ajax({
                type: "post",
                url: "<?php echo url('Role/rolesave_descript'); ?>",
                data: {'id': id, 'value': value,'submit':submit,'field':field},
                dataType: "json",
                success: function (i) {
                    if (i == 1){
                        layer.msg('编辑成功');

                    }else if (i == 2){
                        layer.msg('编辑失败,角色名不能为空');
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            window.location.reload();//页面刷新
                        }, 1000);
                    }else {
                        layer.msg('编辑失败,角色名不能重复');
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            window.location.reload();//页面刷新
                        }, 1000);
                    }
                }
            });
        });
        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('角色描述：' + data.descript);
            } else if (obj.event === 'del') {
                del(data.id);
            } else if (obj.event === 'edit') {
                window.location.href = "<?php echo url('Role/rolesave'); ?>" + "?id=" + data.id;
                //window.location.href="login.jsp?backurl="+window.location.href;
            }
        });
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        table.init('demo', {
            //设置高度
            height: 350
            //注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
//支持所有基础参数
            , page: {
                //自定义分页布局
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
                , curr: 1 //设定初始在第 5 页
            }
            /*, page: {
             layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
             //curr这个参数是控制每页显示的数据条数时间（layout里面的limit是下拉框里面的数据）
             , curr: 1
             }*/
        });
    });
</script>
<!--自动渲染-->
<!--<script>
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.render({
            elem: '#demo' //指定原始表格元素选择器（推荐id选择器）
            ,height: 315 //容器高度
            ,page:true
            //,…… //更多参数参考右侧目录：基本参数选项
        });
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', functadminndex){
                    obj.del();
                    layer.cladminndex);
                });
            } else if(obj.event === 'edit'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });

        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('idTest');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>-->
<!--方法渲染-->
<!--<script>
    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#test'
            ,url:"<?php echo url('Role/index_x'); ?>"
            ,cols: [[
                {type:'checkbox'}
                ,{field:'id', width:80, title: 'ID', sort: true}
                ,{field:'role', width:80, title: '角色'}
                ,{field:'descript', width:80, title: '描述', sort: true}
                ,{fixed: 'right', width:178, align:'center', toolbar: '#barDemo', title: '操作'}
            ]]
            ,page: true
        });
    });
</script>-->

<script>
    function del(id) {
        //alert(id);
        layui.use(['layer'], function () {
            var layer = layui.layer;
            layer.confirm('你确定要删除吗', {icon: 7, title: '提示'}, function (index) {
                //do something
                var submit = "submit";
                $.ajax({
                    type: "post",
                    url: "<?php echo url('Role/roledelete'); ?>",
                    data: {'id': id, 'submit_role_id': submit},
                    dataType: "json",
                    success: function (i) {
                        //alert(i);
                        if (i >= 2) {
                            layer.msg('删除成功', {icon: 1});
                            layer.close(index);
                        }
                        else {
                            if (i == 1) {
                                layer.msg('你没有删除这个角色的权限', {icon: 4});
                                layer.close(index);
                            } else {
                                layer.msg('删除失败', {icon: 2});
                                layer.close(index);
                            }
                        }
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            window.location.reload();//页面刷新
                        }, 2000);
                    }
                });

            });
        });
    }
</script>
</html>